/*
 * @Author: your name
 * @Date: 2020-05-14 22:29:34
 * @LastEditTime: 2020-05-14 23:05:10
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ts\ts_test\more.ts
 */

 //类型 别名
 function sun(x:number,y:number) : number {
   return x + y
 }
 const sum2:(x:number,y:number)=>number = sun

 type PlusType = (x:number,y:number)=>number
 const sunm3:PlusType = sun

 type NameResolver =  ()=>string
 type NameOrRwsolver = string | NameResolver
 function getName(a:NameOrRwsolver) : string{
    if(typeof a === 'string'){
      return a
    }else{
       return a()
    }
 }

 //类型断言 (骗过编译器 该判断 还是得)

 function getLength(input:string | number){
   const str = input as String
   if(str.length){
     return str.length
   }else{
     const number =input as Number
     return number.toString().length
   }
 }

 jQuery("#mydom").offsetParent().addClass
